/* beautify ignore:start */
import {Directive, ElementRef, Renderer, EventEmitter, Input} from '@angular/core';
/* beautify ignore:end */

@Directive({
    selector: '[wm-search]',
    inputs: ['field: wm-search'],
    outputs: ['searchChanged'],
    host: {
        '(input)': 'onChangeFilter($event.target.value)',
        '(click)': 'onChangeFilter($event.target.value)'
    }
})
export class TableSearch {
    public field: string ;  // 查询的字段
    public searchChanged: EventEmitter<any> = new EventEmitter();

    constructor(private el: ElementRef, private renderer: Renderer) {

    }

    onChangeFilter(event: any) {
        this.searchChanged.emit({search: event, field: this.field});
    }

}